package me.yobol.lintcode.easy.clonebt;

import me.yobol.lintcode.TreeNode;

/**
 *
 * @author Yobol
 */
public class CloneBinaryTree implements ICloneBinaryTree{

    /**
     * 
     * @param root the root of binary tree
     * @return the root of new binary tree
     */
    @Override
    public TreeNode cloneTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        TreeNode node = new TreeNode(root.val);
        node.left = cloneTree(root.left);
        node.right = cloneTree(root.right);
        return node;
    }
    
}
